package net.minecraft.src;

import java.util.Random;

public class BlockPrehistoricGrass extends Block
{

    protected BlockPrehistoricGrass(int i, int j)
    {
        super(i, j, Material.grass);
        topTexture = ModLoader.addOverride("/terrain.png", "/pph/grasstop.png");
		bottomTexture = ModLoader.addOverride("/terrain.png", "/pph/dirt.png");
        setTickOnLoad(true);
    }

    public int getBlockTextureFromSide(int i)
    {
        if(i == 0)
        {
            return bottomTexture;
        }
        if(i == 1)
        {
            return topTexture;
        } else
		{
			return blockIndexInTexture;
		}
    }

    public void updateTick(World world, int i, int j, int k, Random random)
    {
        if(world.multiplayerWorld)
        {
            return;
        }
        if(world.getBlockLightValue(i, j + 1, k) < 4 && Block.lightOpacity[world.getBlockId(i, j + 1, k)] > 2)
        {
            if(random.nextInt(4) != 0)
            {
                return;
            }
            world.setBlockWithNotify(i, j, k, mod_pph.prehistoricDirt.blockID);
        } else
        if(world.getBlockLightValue(i, j + 1, k) >= 9)
        {
            int l = (i + random.nextInt(3)) - 1;
            int i1 = (j + random.nextInt(5)) - 3;
            int j1 = (k + random.nextInt(3)) - 1;
            int k1 = world.getBlockId(l, i1 + 1, j1);
            if(world.getBlockId(l, i1, j1) == mod_pph.prehistoricDirt.blockID && world.getBlockLightValue(l, i1 + 1, j1) >= 4 && Block.lightOpacity[k1] <= 2)
            {
                world.setBlockWithNotify(l, i1, j1, mod_pph.prehistoricGrass.blockID);
            }
        }
    }

    public int idDropped(int i, Random random)
    {
		return mod_pph.prehistoricDirt.blockID;

	}
	
	private int topTexture;
	private int bottomTexture;
}
